﻿
namespace MyFurion.Application
{
    /// <summary>
    /// 当前用户信息
    /// </summary>
    public static class CurrentUserInfo
    {
        /// <summary>
        /// 用户id
        /// </summary>
        public static long UserId => (App.User != null && App.User.FindFirst(ClaimConst.ClAIM_USERID) != null) ? long.Parse(App.User.FindFirst(ClaimConst.ClAIM_USERID).Value) : 0;
        /// <summary>
        /// 账号
        /// </summary>
        public static string UserName => (App.User != null && App.User.FindFirst(ClaimConst.ClAIM_USERNAME) != null) ? App.User.FindFirst(ClaimConst.ClAIM_USERNAME).Value : "";
        /// <summary>
        /// 昵称
        /// </summary>
        public static string NickName => (App.User != null && App.User.FindFirst(ClaimConst.ClAIM_NICKNAME) != null) ? App.User.FindFirst(ClaimConst.ClAIM_NICKNAME).Value : "";
        /// <summary>
        /// 是否超级管理员
        /// </summary>
        public static bool IsSuperAdmin => (App.User != null && App.User.FindFirst(ClaimConst.ClAIM_SUPERADMIN) != null) ? bool.Parse(App.User.FindFirst(ClaimConst.ClAIM_SUPERADMIN).Value) : false;
        /// <summary>
        /// 组织机构id
        /// </summary>
        public static long OrgId => (App.User != null && App.User.FindFirst(ClaimConst.ClAIM_ORGID) != null) ? long.Parse(App.User.FindFirst(ClaimConst.ClAIM_ORGID).Value) : 0;
        /// <summary>
        /// 组织机构名称
        /// </summary>
        public static string OrgName => (App.User != null && App.User.FindFirst(ClaimConst.ClAIM_ORGNAME) != null) ? App.User.FindFirst(ClaimConst.ClAIM_ORGNAME).Value : "";
        /// <summary>
        /// 机构数据权限类别
        /// </summary>
        public static int OrgPer => (App.User != null && App.User.FindFirst(ClaimConst.ClAIM_ORGPER) != null) ? int.Parse(App.User.FindFirst(ClaimConst.ClAIM_ORGPER).Value) : 0;
        /// <summary>
        ///机构权限ids
        /// </summary>
        public static string OrgPerId => (App.User != null && App.User.FindFirst(ClaimConst.ClAIM_ORGPERID) != null) ? App.User.FindFirst(ClaimConst.ClAIM_ORGPERID).Value : "";
    }
}
